﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.utils {
    import com.facebook.data.stream.*;

    public class FacebookStreamXMLParser {

        public static function createCommentsArray(_arg1:XMLList, _arg2:Namespace):Array{
            var _local6:XML;
            var _local7:PostCommentData;
            var _local3:Array = [];
            var _local4:uint = _arg1.length();
            var _local5:uint;
            while (_local5 < _local4) {
                _local6 = _arg1[_local5];
                _local7 = new PostCommentData();
                _local7.fromid = FacebookXMLParserUtils.toStringValue(_local6._arg2::fromid[0]);
                _local7.id = FacebookXMLParserUtils.toStringValue(_local6._arg2::id[0]);
                _local7.text = FacebookXMLParserUtils.toStringValue(_local6._arg2::text[0]);
                _local7.time = FacebookXMLParserUtils.toDate(_local6._arg2::time[0]);
                _local3.push(_local7);
                _local5++;
            };
            return (_local3);
        }
        protected static function createMediaArray(_arg1:XML, _arg2:Namespace):Array{
            var _local7:XML;
            var _local8:StreamMediaData;
            if (_arg1 == null){
                return (null);
            };
            var _local3:Array = [];
            var _local4:XMLList = _arg1.children();
            var _local5:uint = _local4.length();
            var _local6:uint;
            while (_local6 < _local5) {
                _local7 = _local4[_local6];
                _local8 = new StreamMediaData();
                _local8.type = FacebookXMLParserUtils.toStringValue(_local7._arg2::type[0]);
                _local8.alt = FacebookXMLParserUtils.toStringValue(_local7._arg2::alt[0]);
                _local8.href = FacebookXMLParserUtils.toStringValue(_local7._arg2::href[0]);
                _local8.src = FacebookXMLParserUtils.toStringValue(_local7._arg2::src[0]);
                _local8.video = createVideoMedia(_local7._arg2::video[0], _arg2);
                _local8.photo = createPhotoMedia(_local7._arg2::photo[0], _arg2);
                _local8.flash = createFlashMedia(_local7._arg2::swf[0], _arg2);
                _local8.music = createMusicMedia(_local7._arg2::music[0], _arg2);
                _local3.push(_local8);
                _local6++;
            };
            return (_local3);
        }
        public static function createStreamFilterCollection(_arg1:XML, _arg2:Namespace):GetFiltersData{
            var _local8:XML;
            var _local9:StreamFilterData;
            var _local3:GetFiltersData = new GetFiltersData();
            var _local4:StreamFilterCollection = new StreamFilterCollection();
            var _local5:XMLList = _arg1.._arg2::stream_filter;
            var _local6:uint = _local5.length();
            var _local7:uint;
            while (_local7 < _local6) {
                _local8 = _local5[_local7];
                _local9 = new StreamFilterData();
                _local9.filter_key = FacebookXMLParserUtils.toStringValue(_local8._arg2::filter_key[0]);
                _local9.icon_url = FacebookXMLParserUtils.toStringValue(_local8._arg2::icon_url[0]);
                _local9.is_visible = FacebookXMLParserUtils.toBoolean(_local8._arg2::is_visible[0]);
                _local9.name = FacebookXMLParserUtils.toStringValue(_local8._arg2::name[0]);
                _local9.rank = FacebookXMLParserUtils.toNumber(_local8._arg2::rank[0]);
                _local9.type = FacebookXMLParserUtils.toStringValue(_local8._arg2::type[0]);
                _local9.uid = FacebookXMLParserUtils.toStringValue(_local8._arg2::uid[0]);
                _local9.value = FacebookXMLParserUtils.toStringValue(_local8._arg2::value[0]);
                _local4.addItem(_local9);
                _local7++;
            };
            _local3.filters = _local4;
            return (_local3);
        }
        protected static function createVideoMedia(_arg1:XML, _arg2:Namespace):VideoMedia{
            if (_arg1 == null){
                return (null);
            };
            var _local3:VideoMedia = new VideoMedia();
            _local3.display_url = FacebookXMLParserUtils.toStringValue(_arg1._arg2::display_url[0]);
            _local3.owner = FacebookXMLParserUtils.toStringValue(_arg1._arg2::owner[0]);
            _local3.permalink = FacebookXMLParserUtils.toStringValue(_arg1._arg2::permalink[0]);
            _local3.source_url = FacebookXMLParserUtils.toStringValue(_arg1._arg2::source_url[0]);
            _local3.preview_img = FacebookXMLParserUtils.toStringValue(_arg1._arg2::preview_img[0]);
            return (_local3);
        }
        protected static function createFlashMedia(_arg1:XML, _arg2:Namespace):FlashMedia{
            if (_arg1 == null){
                return (null);
            };
            var _local3:FlashMedia = new FlashMedia();
            _local3.source_url = FacebookXMLParserUtils.toStringValue(_arg1._arg2::source_url[0]);
            _local3.preview_img = FacebookXMLParserUtils.toStringValue(_arg1._arg2::preview_img[0]);
            return (_local3);
        }
        public static function createGetCommentsData(_arg1:XML, _arg2:Namespace):GetCommentsData{
            var _local3:XMLList = _arg1.._arg2::comment;
            var _local4:GetCommentsData = new GetCommentsData();
            _local4.comments = createCommentsArray(_local3, _arg2);
            return (_local4);
        }
        protected static function createActionLinksArray(_arg1:XML, _arg2:Namespace):Array{
            var _local7:XML;
            var _local8:ActionLinkData;
            if (_arg1 == null){
                return (null);
            };
            var _local3:Array = [];
            var _local4:XMLList = _arg1.children();
            var _local5:uint = _local4.length();
            var _local6:uint;
            while (_local6 < _local5) {
                _local7 = _local4[_local6];
                _local8 = new ActionLinkData();
                _local8.text = FacebookXMLParserUtils.toStringValue(_local7._arg2::text[0]);
                _local8.href = FacebookXMLParserUtils.toStringValue(_local7._arg2::href[0]);
                _local3.push(_local8);
                _local6++;
            };
            return (_local3);
        }
        protected static function createMusicMedia(_arg1:XML, _arg2:Namespace):MusicMedia{
            if (_arg1 == null){
                return (null);
            };
            var _local3:MusicMedia = new MusicMedia();
            _local3.source_url = FacebookXMLParserUtils.toStringValue(_arg1._arg2::source_url[0]);
            _local3.artist = FacebookXMLParserUtils.toStringValue(_arg1._arg2::artist[0]);
            _local3.title = FacebookXMLParserUtils.toStringValue(_arg1._arg2::title[0]);
            return (_local3);
        }
        public static function createStream(_arg1:XML, _arg2:Namespace):GetStreamData{
            var _local6:uint;
            var _local7:uint;
            var _local10:XML;
            var _local11:StreamStoryData;
            var _local12:XML;
            var _local13:AttachmentData;
            var _local14:LikesData;
            var _local15:XML;
            var _local16:XML;
            var _local17:ProfileData;
            var _local18:XML;
            var _local3:GetStreamData = new GetStreamData();
            var _local4:StreamStoryCollection = new StreamStoryCollection();
            var _local5:ProfileCollection = new ProfileCollection();
            _local3.stories = _local4;
            _local3.profiles = _local5;
            var _local8:XMLList = _arg1._arg2::posts.children();
            _local6 = _local8.length();
            _local7 = 0;
            while (_local7 < _local6) {
                _local10 = _local8[_local7];
                _local11 = new StreamStoryData();
                _local11.sourceXML = _local10;
                _local12 = _local10._arg2::attachment[0];
                _local13 = new AttachmentData();
                _local13.name = FacebookXMLParserUtils.toStringValue(_local12._arg2::name[0]);
                _local13.text = FacebookXMLParserUtils.toStringValue(_local12._arg2::text[0]);
                _local13.body = FacebookXMLParserUtils.toStringValue(_local12._arg2::body[0]);
                _local13.icon = FacebookXMLParserUtils.toStringValue(_local12._arg2::icon[0]);
                _local13.label = FacebookXMLParserUtils.toStringValue(_local12._arg2::label[0]);
                _local13.media = createMediaArray(_local12._arg2::media[0], _arg2);
                _local13.title = FacebookXMLParserUtils.toStringValue(_local12._arg2::title[0]);
                _local13.href = FacebookXMLParserUtils.toStringValue(_local12._arg2::href[0]);
                _local13.caption = FacebookXMLParserUtils.toStringValue(_local12._arg2::caption[0]);
                _local13.description = FacebookXMLParserUtils.toStringValue(_local12._arg2::description[0]);
                _local13.properties = FacebookXMLParserUtils.xmlListToObjectArray(_local12.._arg2::stream_property);
                _local11.attachment = _local13;
                _local11.actor_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::actor_id[0]);
                _local11.comments = createComments(_local10._arg2::comments[0], _arg2);
                _local14 = new LikesData();
                _local15 = _local10._arg2::likes[0];
                _local14.can_like = FacebookXMLParserUtils.toBoolean(_local15._arg2::can_like[0]);
                _local14.user_likes = FacebookXMLParserUtils.toBoolean(_local15._arg2::user_likes[0]);
                _local14.count = FacebookXMLParserUtils.toNumber(_local15._arg2::count[0]);
                _local14.friends = FacebookXMLParserUtils.toUIDArray(_local15._arg2::friends[0]);
                _local14.sample = FacebookXMLParserUtils.toUIDArray(_local15._arg2::sample[0]);
                _local14.href = FacebookXMLParserUtils.toStringValue(_local15._arg2::href[0]);
                _local11.likes = _local14;
                _local11.attribution = FacebookXMLParserUtils.toStringValue(_local10._arg2::attribution[0]);
                _local11.app_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::app_id[0]);
                _local11.metadata = FacebookXMLParserUtils.nodeToObject(_local10._arg2::metadata);
                _local11.message = FacebookXMLParserUtils.toStringValue(_local10._arg2::message[0]);
                _local11.source_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::source_id[0]);
                _local11.target_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::target_id[0]);
                _local11.post_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::post_id[0]);
                _local11.updated_time = FacebookXMLParserUtils.toDate(_local10._arg2::updated_time[0]);
                _local11.created_time = FacebookXMLParserUtils.toDate(_local10._arg2::created_time[0]);
                _local11.type = FacebookXMLParserUtils.toNumber(_local10._arg2::type[0]);
                _local11.viewer_id = FacebookXMLParserUtils.toStringValue(_local10._arg2::viewer_id[0]);
                _local16 = _local10._arg2::privacy[0];
                _local11.privacy = FacebookXMLParserUtils.toStringValue(_local16._arg2::value[0]);
                _local11.filter_key = FacebookXMLParserUtils.toStringValue(_local10._arg2::filter_key[0]);
                _local11.permalink = FacebookXMLParserUtils.toStringValue(_local10._arg2::permalink[0]);
                _local11.is_hidden = FacebookXMLParserUtils.toBoolean(_local10._arg2::is_hidden[0]);
                _local11.action_links = createActionLinksArray(_local10._arg2::action_links[0], _arg2);
                _local4.addItem(_local11);
                _local7++;
            };
            var _local9:XMLList = _arg1._arg2::profiles.children();
            _local6 = _local9.length();
            _local7 = 0;
            while (_local7 < _local6) {
                _local17 = new ProfileData();
                _local18 = _local9[_local7];
                _local17.id = FacebookXMLParserUtils.toStringValue(_local18._arg2::id[0]);
                _local17.name = FacebookXMLParserUtils.toStringValue(_local18._arg2::name[0]);
                _local17.pic_square = FacebookXMLParserUtils.toStringValue(_local18._arg2::pic_square[0]);
                _local17.url = FacebookXMLParserUtils.toStringValue(_local18._arg2::url[0]);
                _local5.addItem(_local17);
                _local7++;
            };
            _local3.albums = FacebookXMLParserUtils.createAlbumCollection(_arg1._arg2::albums[0], _arg2);
            return (_local3);
        }
        protected static function createPhotoMedia(_arg1:XML, _arg2:Namespace):PhotoMedia{
            if (_arg1 == null){
                return (null);
            };
            var _local3:PhotoMedia = new PhotoMedia();
            _local3.aid = FacebookXMLParserUtils.toStringValue(_arg1._arg2::aid[0]);
            _local3.index = FacebookXMLParserUtils.toNumber(_arg1._arg2::index[0]);
            _local3.owner = FacebookXMLParserUtils.toStringValue(_arg1._arg2::owner[0]);
            _local3.pid = FacebookXMLParserUtils.toStringValue(_arg1._arg2::pid[0]);
            return (_local3);
        }
        protected static function createComments(_arg1:XML, _arg2:Namespace):CommentsData{
            var _local3:CommentsData = new CommentsData();
            _local3.can_remove = FacebookXMLParserUtils.toBoolean(_arg1._arg2::can_remove[0]);
            _local3.can_post = FacebookXMLParserUtils.toBoolean(_arg1._arg2::can_post[0]);
            _local3.count = FacebookXMLParserUtils.toNumber(_arg1._arg2::count[0]);
            var _local4:XMLList = _arg1._arg2::comment_list.children();
            _local3.posts = createCommentsArray(_local4, _arg2);
            return (_local3);
        }

    }
}//package com.facebook.utils 
